package com.mrx.agent.plugin;

import com.mrx.agent.advice.TestAdvice;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.asm.Advice;

import java.util.List;
import java.util.Set;

import static net.bytebuddy.matcher.ElementMatchers.named;

/**
 * @author Mr.X
 * @since 2024/11/5 20:14
 */
public class TestPlugin extends BasePlugin {

    @Override
    public List<AgentBuilder.Transformer> transformers() {
        return List.of(transformer());
    }

    @Override
    public Set<String> dependencies() {
        return Set.of(TestAdvice.class.getName());
    }

    private XTransformer transformer() {
        return (it, type) -> {
            log("transformer: " + type.getName());
            return it.visit(Advice.to(TestAdvice.class).on(named("test")));
        };
    }

}
